package cts.action;

import java.util.List;
import java.util.Set;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import cts.business.UserOP;
import cts.db.Exam;

public class UserAction extends ActionSupport {

	/**
	 * @return
	 */
	UserOP userOP = new UserOP();
	String uname;
	String pwd;
	String message;
	
	
	public String execute() {
		// TODO Auto-generated method stub
		return SUCCESS;
	}
	
	public String login(){
		int loginResult = userOP.login(uname,pwd);
		if(loginResult>0){
			ActionContext.getContext().getSession().put("uid", loginResult);
			ActionContext.getContext().getSession().put("uname", uname);
			return SUCCESS;
		}
		else{
			message = new String("用户名密码错误");
			return INPUT;
		}
	}
	
	

	
	//getter and setter
	public String getUname() {
		return uname;
	}

	public void setUname(String uname) {
		this.uname = uname;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
	
	
}